package ohshit
import (
	"fmt"
	"net"
)
func Run(){
	 lst:=make([]string,0)
	lst=append(lst,"183.234.49.190:9100","183.234.49.190:9800","www.baidu.com:80")
	for _,addr:=range lst{
		go IsWebsiteActive(addr)
	}
}
//测试网站是否连通
func IsWebsiteActive(addr string)  bool{
	var success bool
	tcpAddr, err := net.ResolveTCPAddr("tcp4",addr)// "183.234.49.190:9800")  //换成www.baidu.com:80试一试
	if err!=nil{
		fmt.Println("error: ",err)
		success=false
	}

	_, err = net.DialTCP("tcp", nil, tcpAddr)
	if err!=nil{
		fmt.Println("error: ",err)
		success=false
	}else{
		fmt.Println("connect success")
		success=true
	}

	return success
}
